package com.apache.flow.core.manager;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.apache.flow.core.dao.FlowLockDao;
import com.apache.flow.vo.FlowLockQvo;
import com.apache.uct.common.entity.Lock;

@Service
@Transactional
public class FlowLockManager {
	@Autowired
	private FlowLockDao lockDao;

	/**
	 * 根据id得到资源
	 * @param id
	 * @return Lock
	 */
	@Transactional(readOnly = true)
	public Lock getLock(String id) {
		return lockDao.get(id);
	}

	/**
	 * 获得所有资源
	 * @return List<Lock>
	 * @throws UctLockException 
	 */
	@Transactional(readOnly = true)
	public List<Lock> getAllLock() throws Exception {
		return lockDao.getAllLock();
	}

	/**
	 * 删除资源
	 * @param id
	 */
	public void deleteLock(String id) {
		lockDao.delete(id);
	}

	/**
	 * 取到资源分页信息
	 * @param qvo
	 * @param pageNo
	 * @param pageSize
	 * @return Page<Lock>
	 * @throws UctLockException 
	 */
	@Transactional(readOnly = true)
	public List<Lock> getLockListByQvo(FlowLockQvo qvo, int pageNo, int pageSize) throws Exception {
		return lockDao.getLockListByQvo(qvo, pageNo, pageSize);
	}

}
